package org.amphiprion.rfreplayanalyser.util;

import org.amphiprion.rfreplayanalyser.parser.Score;

public class ScoreUtil {
	public static boolean isRankingChanged(Score score1, Score score2) {
		long[] rank1 = score1.getDriverPlaces();
		long[] rank2 = score2.getDriverPlaces();
		if (rank1.length != rank2.length) {
			return true;
		}
		for (int i = 0; i < rank1.length; i++) {
			if (rank1[i] != rank2[i]) {
				return true;
			}
		}
		return false;
	}

	public static int getRank(Score score, long driverId) {
		for (int i = 0; i < score.getDriverPlaces().length; i++) {
			if (score.getDriverPlaces()[i] == driverId) {
				return i + 1;
			}
		}
		return Integer.MAX_VALUE;
	}
}
